package com.cat.greedyAlgorithm;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/smallest-missing-non-negative-integer-after-operations/?envType=daily-question&envId=2025-10-16
 * @create 2025/10/16 15:23
 * @since JDK17
 */

public class Solution92 {
    public int findSmallestInteger(int[] nums, int value) {
        int[] cnt = new int[value];
        for (int num : nums) {
            cnt[(num % value + value) % value]++;
        }
        int min = Integer.MAX_VALUE, ans = -1;
        for (int i = 0; i < value; i++) {
            if (min > nums[i]) {
                min = nums[i];
                ans = i;
            }
        }
        return min * value + ans;
    }
}
